package com.guit.hrms.po.utilsPO;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code; //状态码 0成功 1失败
    private String msg; //提示信息
    private T data; //响应数据

    public Result() {
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    //快速返回操作成功响应结果（带响应数据）
    public static <E> Result<E> success(E data){
        return new Result<>(1,"success",data);
    }

    //快速返回操作成功响应结果
    public static Result success(){
        return new Result<>(1,"success",null);
    }

    public static Result error(String data){
        return new Result<>(0,"error",data);
    }

    public static Result error(){
        return new Result<>(0,"error",null);
    }
}

